package com.cmw.core.util;

public class HtmlEncode {
	
	
    public static String encode(String source) {
        if (source == null) {
            return "";
        }
        String html = "";
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < source.length(); i++) {
            char c = source.charAt(i);
            switch (c) {
            case '<':
                buffer.append("XIAOYUXIAOYU");
                break;
            case '>':
                buffer.append("DAYUDAYU");
                break;
            case '&':
                buffer.append("ANDEANDE");
                break;
            case '"':
                buffer.append("YINHAOYINHAO");
                break;
            case '\n':
            	buffer.append("BACKSLASH_N");
                break;
            default:
                buffer.append(c);
            }
        }
        html = buffer.toString();
        return html;
    }
    
    
}